<%@ page import="com.pojo.User" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: pc
  Date: 2025/8/18
  Time: 10:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<%--java小脚本：是可以写java代码--%>
<script src="statics/js/jquery-3.7.1.min.js"></script>
<script>
    $(function () {
            $(".del").click(function (event) {
                 var id= event.target.name;
                 let isOk=confirm("是否要删除编号为["+id+"]的数据")
                 if(isOk){
                     $.ajax({
                         url:"/user?type=delUser&&id="+id,
                         type:"GET",
                         dataType:"json",
                         success:function (res) {
                             if(res.state==200){
                                 alert(res.msg);
                                 location.href="/user?type=getUserAll";
                             }else {
                                 alert(res.msg);
                             }
                         }
                     })
                 }else {
                     alert("取消删除")
                 }
            })
    })
</script>

<style>
    .menu {
        border: solid 1px red;
        width: 100px;
        height: 200px;
    }

</style>
<body>
<%--java小脚本表达式--%>
    <p>首页${sessionScope.user.name}录成功</p>
    <a href="cat.jsp">购物车</a>
    <a href="addUser.jsp">新增</a>
<%--jstl标签--%>
  <div>
      <div class="menu">
         <ul>
             <c:forEach var="menus" items="${sessionScope.menusAll}" varStatus="s" >
                 <li><a href="${menus.hrefUrl}&&pid=${menus.id}">${menus.mName}</a></li>
             </c:forEach>
         </ul>
      </div>

     <div class="table">
         <div>
             <c:forEach var="btn" items="${sessionScope.menusBtn}" varStatus="s">
                 ${btn.hrefUrl}
             </c:forEach>
         </div>
         <table>
             <tr>
                 <td>用户编号</td>
                 <td>用户名</td>
                 <td>用户密码</td>
                 <td>操作</td>
             </tr>
             <c:forEach var="user" items="${sessionScope.userAll}" varStatus="s">
                 <tr>
                         <%--   <c:if test="${user.id==6}">--%>
                     <td>${user.id}</td>
                     <td>${user.name}</td>
                     <td>${user.password}</td>
                     <%--<td><a href="javaScript:void(0)" name="${user.id}" class="del">删除</a></td>
                     <td><a href="/user?type=getUserById&&id=${user.id}">修改</a></td>--%>
                         <%--</c:if>--%>
                 </tr>
             </c:forEach>
         </table>
     </div>
  </div>

</body>
</html>
